package com.example.controller.adm;

import java.util.Arrays;
import java.util.List;

import com.alibaba.fastjson.JSONArray;
import io.swagger.annotations.ApiOperation;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.example.vo.ResultVo;
import com.github.pagehelper.PageInfo;
import com.example.pojo.GsRestoreRecord;
import com.example.service.IGsRestoreRecordService;
import io.swagger.annotations.Api;
/**
 * <p>
 * 物品归还记录表 前端控制器
 * </p>
 *
 * @author wsl
 * @since 2022-05-12
 */
@RestController
@RequestMapping("/gsRestoreRecord")
@Api(tags = "物品归还记录表",value = "")
@CrossOrigin(allowCredentials = "true")
public class GsRestoreRecordController {

    @Autowired
    private IGsRestoreRecordService gsRestoreRecordService;

    @ApiOperation(value = "查询物品归还记录表")
    @GetMapping("/query")
    public ResultVo selectGsRestoreRecord(String emp_name,String name) {
        return gsRestoreRecordService.selectGsRestoreRecord(emp_name,name);
    }

    @ApiOperation(value = "新增物品归还记录表")
    @PostMapping("/add")
    public ResultVo addGsRestoreRecord(@RequestBody JSONArray jsonArray) {
        List<GsRestoreRecord> list = jsonArray.toJavaList(GsRestoreRecord.class);
        for (GsRestoreRecord gsRestoreRecord : list) {
            gsRestoreRecordService.save(gsRestoreRecord);
        }
        return ResultVo.ok("是");
    }
//
//    @ApiOperation(value = "修改物品归还记录表")
//    @PutMapping("/update")
//    public ResultVo updateGsRestoreRecord(@RequestBody GsRestoreRecord gsRestoreRecord) {
//        if (gsRestoreRecordService.updateById(gsRestoreRecord)) {
//            return ResultVo.success("修改成功。");
//        }
//        return ResultVo.error("修改失败!");
//    }
//
//    @ApiOperation(value = "删除物品归还记录表")
//    @DeleteMapping("/delete")
//    public ResultVo deleteGsRestoreRecord(Integer[] ids){
//        if(gsRestoreRecordService.removeByIds(Arrays.asList(ids))){
//            return ResultVo.ok();
//        }
//        return ResultVo.error();
//    }
}
